//
//  VMCUserApi.m
//  vmcshop
//
//  Created by bigknife on 14/11/6.
//  Copyright (c) 2014年 idongler. All rights reserved.
//

#import "VMCUserApi.h"

@implementation VMCUserApi
+(instancetype) sharedInstance {
    static VMCUserApi *instance;
    static dispatch_once_t onceToken;
    dispatch_once(&onceToken, ^{
        instance = [[self alloc]init];
    });
    return instance;
}

-(void) loginUserWithLoginName:(NSString *)loginName andPassword:(NSString *)password callback:(API_CALLBACK)callback {
    ApiRequest *request = [ApiRequest requestWithBizData:@{
                                                           @"uname" : EMPTY_IF_NIL(loginName),
                                                           @"password" : EMPTY_IF_NIL(password)
                                                        }];
    [self postApi:@"emc_passport/login" andRequest:request callback:callback];
}

-(void) logoutWithSession:(NSString *)session callback:(API_CALLBACK)callback{
    ApiRequest *request = [ApiRequest requestWithBizData:@{@"session":EMPTY_IF_NIL(session)}];
    [self postApi:@"emc_passport/loginout" andRequest:request callback:callback];

}

-(void) registerUserWithMobile:(NSString *)mobile
						  name:(NSString *)name
                      password:(NSString *)password
                         vcode:(NSString *)vcode
                      callback:(API_CALLBACK)callback{
    ApiRequest *request = [ApiRequest requestWithBizData:@{
                                                           @"mobile" : EMPTY_IF_NIL(mobile),
														   @"name" : EMPTY_IF_NIL(name),
                                                           @"password" :EMPTY_IF_NIL(password),
                                                           @"vcode" : EMPTY_IF_NIL(vcode)
                                                           }];
    [self postApi:@"emc_passport/signup" andRequest:request callback:callback];

}

-(void)loadMyFavListWithQueryParam:(VMCListQueryParam *)queryParam
						   callback:(API_CALLBACK)callback {

	ApiRequest *request = [ApiRequest requestWithBizData:[queryParam asDict]];
	[self postApi:@"emc_member/fav_list" andRequest:request callback:callback];

}

-(void)addGoods:(NSString *)goodsId toMyFavWithCallback:(API_CALLBACK)callback{
	ApiRequest *request = [ApiRequest requestWithBizData:@{@"goodsId" : EMPTY_IF_NIL(goodsId)}];
	[self postApi:@"emc_member/fav_add" andRequest:request callback:callback];
}
-(void)deleteGoods:(NSString *)goodsId formMyFavWithCallback:(API_CALLBACK)callback{
	ApiRequest *request = [ApiRequest requestWithBizData:@{@"goodsId" : EMPTY_IF_NIL(goodsId)}];
	[self postApi:@"emc_member/fav_remove" andRequest:request callback:callback];
}


-(void)loadmyCouponsWithQueryParam:(VMCListQueryParam *)queryParam callback:(API_CALLBACK)callback{
	ApiRequest *request = [ApiRequest requestWithBizData:[queryParam asDict]];
	[self postApi:@"emc_member/coupon_list" andRequest:request callback:callback];

}

-(void)loadmyWuLiuWithOrderID:(NSString *)orderID callback:(API_CALLBACK)callback{
	
	NSLog(@"%@",orderID);
	
	 ApiRequest *request = [ApiRequest requestWithBizData:@{@"orderId" : EMPTY_IF_NIL(orderID)}];
	[self postApi:@"emc_member/order_delivery_info" andRequest:request callback:callback];
	
}

-(void) loadMyMessageCount:(API_CALLBACK)callback {
	ApiRequest *request = [ApiRequest requestWithBizData:@{}];
	[self postApi:@"emc_member/message_num" andRequest:request callback:callback];
	
}

-(void)loadMyInfo:(API_CALLBACK)callback
{
	ApiRequest *request = [ApiRequest requestWithBizData:@{}];
	[self postApi:@"emc_member/info" andRequest:request callback:callback];
}

- (void)checkIsFavWith:(NSString *)goodId callback:(API_CALLBACK)callback{
	ApiRequest *request = [ApiRequest requestWithBizData:@{@"goodsId":EMPTY_IF_NIL(goodId)}];
	[self postApi:@"emc_member/is_fav" andRequest:request callback:callback];
}
#pragma mark - 我的分佣
- (void)loadmyCommissionOrderList:(API_CALLBACK)callback{
	ApiRequest *request = [ApiRequest requestWithBizData:@{}];
	[self postApi:@"emc_member/fenyong" andRequest:request callback:callback];
}
#pragma mark - 处方单记录
- (void)loadmyRecipelList:(API_CALLBACK)callback{
	ApiRequest * request = [ApiRequest requestWithBizData:@{}];
	[self postApi:@"emc_member/get_prescription" andRequest:request callback:callback];
}

#pragma mark - 咨询记录
- (void)loadAdvusiryList:(API_CALLBACK)callback{
	ApiRequest * request = [ApiRequest requestWithBizData:@{}];
	[self postApi:@"emc_product/ask_list" andRequest:request callback:callback];
}
@end
